import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.Vector;


public class Circle extends Shape {
	double radius;

	public Circle(double r){
		super();
		radius = r;
	}
	
	public double getRadius() {
		return radius;
	}

	public void setRadius(double radius) {
		this.radius = radius;
	}
	
	public Vector<Line> getLineDistribution(double granularity){
		Vector<Line> res = new Vector<Line>();
		
		int n = (int) Math.ceil(2 * Math.PI * radius / granularity);
		double delta = 2 * Math.PI / n;
		
		for (int i = 0; i < n ; i++){
			Line line = new Line(radius, granularity);
			line.setDirectionRad(delta * i);
			line.origin = (Point2D.Double) origin.clone();
			res.add(line);
		}
		
		return res;
	}
	
	public Vector<Circle> getCircleDistribution(double granularity){
		Vector<Circle> res = new Vector<Circle>();
		
		int m = (int) Math.ceil((radius / (granularity * 0.9))); // <-
		double deltaM = radius / m;
		
		int n;
		double deltaN;
		for (int i = 1; i <= m ; i++){
			n = (int) Math.ceil(2 * Math.PI * deltaM * i / granularity); // <-
			deltaN = 2 * Math.PI / n;
			for (int j = 0; j <= n ; j++){
				Circle circle = new Circle(granularity/2);
				circle.setOrigin(origin.x + Math.cos(deltaN * j) * deltaM * i, origin.y + Math.sin(deltaN * j) * deltaM * i);
				res.add(circle);
			}
		}
		
		return res;
	}
}
